package Lee_code;

import redbook.Main;

import javax.swing.*;
import java.util.Arrays;

/**
 * @author blh
 * @date 2024年10月18日 17:17
 */
public class Lee_274_1018 {
    public int hIndex(int[] citations) {
        int maxH = Arrays.stream(citations).max().getAsInt();
        for (int h = maxH; h > 0; h--) {
            int count = 0;
            for (int citation : citations) {
                if (citation >= h) {
                    count++;
                }
            }
            if (count >= h) {
                return h;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        Lee_274_1018 method = new Lee_274_1018();
        method.hIndex(new int[]{1, 3, 1});
    }
}
